package com.bmps.springcloud.insuredmicroservice.controller;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
@Component
public class LoadRedisRunner implements ApplicationRunner {
    @Autowired
    RedisTemplate redisTemplate;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        // 销售渠道
        List<String> agentList = Arrays.asList("HZ01", "BT01");
        redisTemplate.opsForValue().set("D005|agentcom", agentList, 10, TimeUnit.HOURS);
        // R004|HC010 1000.00|0||||4|A|106|M
        redisTemplate.opsForValue().set("R004|HCT010", "1000.00|0||||4|A|106|M", 10, TimeUnit.HOURS);
        // r001 "AppAge|Sex|PayEndYear"
        redisTemplate.opsForValue().set("R001|HCT010|G", "PayIntv|AppAge|Sex|PayEndYear", 10, TimeUnit.HOURS);
        // R006|HCT010|G a/b*c*d
        redisTemplate.opsForValue().set("R006|HCT010|G", "a/b*c*d", 10, TimeUnit.HOURS);
        // R005|HCT010|G
        // {"@type":"java.util.HashMap","a":"Get","b":"VPU","c":"Rate","d":"PayIntvRate"}
        Map<String, String> map = new HashMap();
        map.put("a", "Get");
        map.put("b", "VPU");
        map.put("c", "Rate");
        map.put("d", "PayIntvRate");
        redisTemplate.opsForValue().set("R005|HCT010|G", map, 10, TimeUnit.HOURS);
        // R003|HCT010|G|12|42|0|10
        redisTemplate.opsForValue().set("R003|HCT010|G|12|42|0|10", 58.5, 10, TimeUnit.HOURS);
    }

}